|
|
|
|
<Array>.Map (Function) In french: <Tableau>.Transforme Executes a procedure on each element of a source array and returns the results in a WLanguage array. This function can be used: - on one-dimensional arrays s,
New in version 2024about arrays associations.
tab1 is array of strings = ["A", "b", "C"]
tab1 = tab1.Transforme(X => Lower(X))
Syntax
<Result> = <Source array>.Map(<Operation to perform>)
<Result>: WLanguage array Array that contains the result of the procedure executed for each element of the <Source array>. <Source array>: WLanguage array Name of the Array variable to use. This array can be: - a one-dimensional array.
New in version 2024an array association.
<Operation to perform>: WLanguage procedure Name of the WLanguage procedure to be executed for each element of the <Source array>. This procedure can be: - a global or local procedure,
- an internal procedure.
It is also possible to directly use a lambda procedure. Remarks Operating mode The Procedure is called for each element of the source array by passing the parameter: - the array source element,
New in version 2024the key to the element. In the case of a simple array, the key corresponds to the element index. This parameter is optional. In the case of an associative array, the key corresponds to the element indexing key..
The results of all calls are stored in the <Result> array. Sequence of functionsYou can use array functions in a sequence. The following functions can be used in a sequence: This sequence can be used as a source for a FOR ALL statement or it can end with one of the following functions: Example: gnMoyenne = gtabUser.Filtre(cbFiltre).Map(cbTransforme).Mean()
Related Examples:
|
Unit examples (WINDEV): Filter / Map / Reduce
[ + ] This example shows how to use the Filter / Map / Reduce functions. The Filter / Map / Reduce concept allows performing operations on sets of data in a remarkably concise way. Filter is used to filter an array of elements in a customized way (with a callback procedure). Map is used to transform an array of elements, also with a callback procedure. Reduce is used to aggregate data in a customized way with a callback procedure. Here, this example is used to calculate the average age of women among the users displayed in the table below.
|
Business / UI classification: Neutral code
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|